package com.ez.supervise.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ez.supervise.core.Page;
import com.ez.supervise.dao.UserAddressDao;
import com.ez.supervise.dao.base.BaseDaoImpl;
import com.ez.supervise.model.biz.UserAddress;

public class UserAddressDaoImpl extends BaseDaoImpl implements UserAddressDao {

    public void insert(Object userAddress) {
	sqlMapClientTemplate.insert("biz.insertUserAddress", userAddress);
    }

    public Object get(Long id) {
	return (UserAddress) sqlMapClientTemplate.queryForObject("biz.getUserAddressById", id);
    }

    public void update(Object userAddress) {
	sqlMapClientTemplate.update("biz.updateUserAddress", userAddress);
    }

    public void delete(Long id) {
	sqlMapClientTemplate.delete("biz.deleteUserAddress", id);
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.UserDao#findByCount(com.ez.supervise.core.Page)
     */
    public int findUserAddressByCount(Page page) {
	return (Integer) getSqlMapClientTemplate().queryForObject("biz.findUserAddressByCount", page.getConditions());
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.UserDao#findByPage(com.ez.supervise.core.Page)
     */
    public List findUserAddressByPage(Page page) {
	return getSqlMapClientTemplate().queryForList("biz.findUserAddressByPage", page.getConditions());
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.UserDao#findAllUser()
     */
    public List findAllUserAddress(String userName) {
	return getSqlMapClientTemplate().queryForList("biz.findAllUserAddress", userName);
    }

    public void publish(Long id, String publishStatus) {
	Map map = new HashMap();
	map.put("id", id);
	map.put("status", publishStatus);
	getSqlMapClientTemplate().update("biz.publishUserAddress", map);
	
    }

    public List findUserAddressByPublish() {
	return getSqlMapClientTemplate().queryForList("biz.findUserAddressByPublish");
  }


}
